package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.saas.domain.dao.InvoiceRelationshipDao;
import com.xbongbong.saas.domain.entity.InvoiceRelationshipEntity;
import com.xbongbong.saas.model.InvoiceRelationshipModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author feng.zheng
 * @version v1.0
 * @date 2019/2/26 16:19
 * @since v1.0
 */
@Service("invoiceRelationshipModel")
public class InvoiceRelationshipModelImpl implements InvoiceRelationshipModel {

    @Resource
    private InvoiceRelationshipDao dao;

    /**
     * 插入
     *
     * @param entity 实体
     * @return 是否成功
     * @throws XbbException 数据库操作异常
     */
    @Override
    public Integer insert(InvoiceRelationshipEntity entity) throws XbbException {
        return dao.insert(entity);
    }

    /**
     * 更新
     *
     * @param entity 实体
     * @return 是否成功
     * @throws XbbException 数据库操作异常
     */
    @Override
    public Integer update(InvoiceRelationshipEntity entity) throws XbbException {
        return dao.update(entity);
    }

    /**
     * 根据参数获取
     *
     * @param param 参数
     * @return java.util.List<com.xbongbong.saas.domain.entity.ext.InvoiceRelationshipEntity>
     * @author feng.zheng
     * @date 2019/2/26 15:41
     */
    @Override
    public List<InvoiceRelationshipEntity> findEntitys(Map<String, Object> param) {
        return dao.findEntitys(param);
    }

    /**
     * 批量插入
     *
     * @param list 集合
     */
    @Override
    public void batchInsert(List<InvoiceRelationshipEntity> list) {
        dao.batchInsert(list);
    }

    /**
     * 批量更新
     * @param list
     */
    @Override
    public void updateBatchSerialNo(List<InvoiceRelationshipEntity> list) {
        dao.updateBatchSerialNo(list);
    }
    @Override
    public void updateBatchMoney(String corpid, List<InvoiceRelationshipEntity> list) {
        dao.updateBatchMoney(corpid, list);
    }

    /**
     * 获取符合查询条件的记录总数
     *
     * @param param 查询条件
     * @return 符合查询条件的记录总数
     */
    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return dao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    /**
     * 数据单条查询
     *
     * @param key    主键ID
     * @param corpid 公司ID
     * @return Integer
     * @author feng.zheng
     * @date 2019/1/23 20:27
     * @since v1.0
     */
    @Override
    public InvoiceRelationshipEntity getByKey(Long key, String corpid) {
        return dao.getByKey(key, corpid);
    }

    /**
     * 根据发票id删除
     *
     * @param invoiceId 发票id
     * @param corpid    公司id
     * @return java.lang.Integer
     * @author feng.zheng
     * @date 2019/2/26 16:18
     */
    @Override
    public Integer deleteByInvoiceId(Long invoiceId, String corpid) {
        return dao.deleteByInvoiceId(invoiceId, corpid);
    }

    /**
     * 根据发票id删除
     *
     * @param invoiceIdIn 发票id集合
     * @param corpid      公司id
     * @return java.lang.Integer
     * @author feng.zheng
     * @date 2019/2/26 16:18
     */
    @Override
    public Integer deleteByInvoiceIdIn(List<Long> invoiceIdIn, String corpid) {
        return dao.deleteByInvoiceIdIn(invoiceIdIn, corpid);
    }

    @Override
    public List<InvoiceRelationshipEntity> getByParam(Map<String, Object> map) {
        return dao.getByParam(map);
    }

    @Override
    public List<Map<String, Object>> getSumMoneyOfContract(Map<String, Object> param) {
        return dao.getSumMoneyOfContract(param);
    }

    @Override
    public List<Map<String, Object>> getSumMoneyofPayment(Map<String, Object> param) {
        return dao.getSumMoneyOfPayment(param);
    }

    @Override
    public List<Map<String, Object>> getSumMoneyofPaymentSheet(Map<String, Object> param) {
        return dao.getSumMoneyOfPaymentSheet(param);
    }

    @Override
    public Integer getCountPaymentOrContract(Map<String, Object> param) {
        return dao.getCountPaymentOrContract(param);
    }

    @Override
    public Integer getCountPayment(Map<String, Object> param) {
        return dao.getCountPayment(param);
    }

    @Override
    public Integer getCountPaymentSheet(Map<String, Object> param) {
        return dao.getCountPaymentSheet(param);
    }

    @Override
    public void updateIsCancel(Integer isCancel, Map<String, Object> param) {
        dao.updateIsCancel(isCancel, param);
    }
}
